# from selenium import webdriver
# from common.conmon import SelectFunction
# import urllib.request
# import datetime
# import time
# import os
# #下载验证码图片
# class save_img(SelectFunction):
#     # global imgPath
#     def save_img(self):
#         # driver=webdriver.Chrome()
#         # url='https://image.baidu.com/search/index?ct=201326592&z=&tn=baiduimage&ipn=r&word=%E5%A3%81%E7%BA%B8%20%E5%90%8D%E8%BD%A6%20%E5%85%B0%E5%8D%9A%E5%9F%BA%E5%B0%BC&pn=0&istype=2&ie=utf-8&oe=utf-8&cl=2&lm=-1&st=-1&fr=&fmq=&ic=0&se=&sme=&width=&height=&face=0'
#         # driver.get(url)
#         # driver.maximize_window()
#         if not os.path.exists('soures_img'):
#             os.mkdir('soures_img')
#         i=0
#         while i<40:
#             check_url=self.element('xpath','//*[@id="imgid"]/div/ul//a/img').get_attribute("src")
#             print(check_url)
#             check_img=urllib.request.urlopen(check_url)
#             data=check_img.read()
#             imgPath='soures_img/%s.png'%(time.strftime("%Y%m%d%H%M%S"))
#             print(imgPath)
#             with open(imgPath,'wb') as f:
#                 f.write((data))
#             time.sleep(3)
#         i += 1
# driver=webdriver.Chrome()
# url = 'https://image.baidu.com/search/index?ct=201326592&z=&tn=baiduimage&ipn=r&word=%E5%A3%81%E7%BA%B8%20%E5%90%8D%E8%BD%A6%20%E5%85%B0%E5%8D%9A%E5%9F%BA%E5%B0%BC&pn=0&istype=2&ie=utf-8&oe=utf-8&cl=2&lm=-1&st=-1&fr=&fmq=&ic=0&se=&sme=&width=&height=&face=0'
# driver.get(url)
# driver.maximize_window()
# aa=save_img(driver)
# aa.save_img

import re  # 正则表达式
import requests  # 爬虫
import os
import time

url = 'https://image.baidu.com/search/index?tn=baiduimage&ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fm=index&fr=&hs=0&xthttps=111110&sf=1&fmq=&pv=&ic=0&nc=1&z=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&ie=utf-8&word=%E9%A3%8E%E6%99%AF%E5%A3%81%E7%BA%B8&f=3&oq=%E9%A3%8E%E6%99%AF&rsp=2'
req = requests.get(url)  # 获取网页的所有内容
url_pic = re.findall('data-imgurl="(.*?)!s"', req.text)  # 获取所有图片的地址的列表
print(req.text)
print(url_pic)
# for one in url_pic:
#     print(f'{one}!s')  # !s小图,!d大图





































